import {KASEO_DEV_MEM_SIZE} from "./KaseoConfigs";
import KaseoDevice from "./KaseoDevice";

export default class KaseoDeviceInterface {
    public readonly $$devtype: symbol
    public readonly $$devname: string
    public __$$devAdaptor: KaseoDevice | null = null;

    protected constructor(devTypeSymbol: symbol, devName: string) {
        this.$$devtype = devTypeSymbol
        this.$$devname = devName
    }

    __$$initDevAdaptor(adaptor: KaseoDevice) { this.__$$devAdaptor = adaptor }

    writeMem(addr: number, o: any) {
        this.__$$devAdaptor? (this.__$$devAdaptor.devmem[addr] = o) : undefined
    }

    readMem(addr: number): any | undefined {
        return this.__$$devAdaptor?.devmem[addr]
    }

    knockHost() {
        this.__$$devAdaptor?.knockHost(this.$$devtype)
    }
    
    /* event functions */
    $$devSetup() {}
    $$devTickBefore() {}
    $$devTickAfter() {}
}
